package com.gitee.poi.plugin.core.handler;

import com.gitee.poi.plugin.annotations.core.Column;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.Sheet;

import java.lang.reflect.Field;

public class ColumnProcessor extends AbstractProcessor implements HandlerAnnotation {

    private Class supportAnnotation = Column.class;

    public CellStyle process(Font font, CellStyle style, Sheet sheet, Field field) {
        Column column = field.getAnnotation(Column.class);
        font.setBold(column.bold());
        font.setFontName(column.fontName());
        font.setItalic(column.italic());
        font.setFontHeightInPoints(column.fontSize());
        font.setColor(column.color().getIndex());
        font.setUnderline(column.underline());
        style.setFont(font);
        style.setWrapText(column.wrapText());
        style.setAlignment(column.align());
        style.setVerticalAlignment(column.verticalAlign());
        return style;
    }

    public Class getSupportAnnotation() {
        return supportAnnotation;
    }
}
